package dlwntk6545.swing.jdbc;

public class J26_SungJukService {
	
	private static J26_SungJukDAO sdao;
	
	
	public boolean createSungJuk(J26_SungJukVO sj){
		sdao = new J26_SungJukDAO();
		return sdao.insertSungJuk(sj);
		
		
	}
	
	//총점, 평균, 학점   계산
	public void computeSungJuk(J26_SungJukVO sj){
		
		int tot = Integer.parseInt(sj.getKor()) + 
				Integer.parseInt(sj.getEng()) + Integer.parseInt(sj.getMat());
		
		float avg = (float)tot / 3;
		
		switch((int)avg / 10){
		
			case 10 : 
				System.out.println("만점"); break;
		
			case 9 : 
				System.out.println("A"); break;
				
			case 8 : 
				System.out.println("B"); break;
				
			case 7 : 
				System.out.println("C"); break;
				
			case 6 : 
				System.out.println("D"); break;
				
			default : 
				System.out.println("F"); break;
				
		}
		
		sj.setTot(tot + "");
		sj.setAvg(avg + "");
		
		
	}
	
}
